import request from "@/axios/request";
import { defineStore } from "pinia";
import { store } from "./store";
import { computed, ref } from "vue";
export const useResourceStore = defineStore("pluginConfig", () => {
  const uploadUrl = ref(window.globalconfig_baseURL + "api/Resource/Upload");

  function download(params) {
    const url =
      window.globalconfig_baseURL +
      "api/Resource/Download?fileId=" +
      params.fileId;
    console.log("url", url);
    window.open(url, "_blank");
  }
  function getResourceInfo(params) {
    return request.get({
      url: "/api/Resource/GetResourceInfo",
      method: "get",
      params: params,
    });
  }
  return {
    uploadUrl,
    download,
    getResourceInfo,
  };
});

export const useResourceWithOut = () => {
  return useResourceStore(store);
};
